package com.qf.test;

import com.qf.daomain.Perm;
import com.qf.daomain.Role;
import com.qf.daomain.Shoe;
import com.qf.mapper.RoleMapper;
import com.qf.mapper.ShoeMapper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.InputStream;
import java.util.HashSet;
import java.util.Set;

/**
 * @author 10537
 * @version V1.0
 * @Date 2021/9/26 15:23
 */

public class Demo7 {
    @Test
    public void Test ()throws Exception{
        InputStream inputStream = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = build.openSession();
        ShoeMapper mapper = sqlSession.getMapper(ShoeMapper.class);
        Shoe shoe=new Shoe();
        shoe.setBrand("耐克");
        shoe.setColor("白色");
        shoe.setStyle("篮球鞋");
        shoe.setId(1);
        //mapper.findShoeByCondition(shoe);
        //mapper.updateById(shoe);
        int a[]={5,6};
        mapper.deleteByIdIn(a);
        Set<Shoe> shoeSet=new HashSet<>();
        shoeSet.add(shoe);
        mapper.bulkInsert(shoeSet);
    }
}
